using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using FastSpring.Base.Model;

namespace FastSpring.Web.Ajax
{
    public class AjaxSecurityUtils
    {
        public static void AjaxSecurity(Object obj)
        {
            if (obj is IList)
            {
                AjaxSecurity(obj as IList);
            }
            else if (obj is AjaxActionResult)
            {
                AjaxSecurity(obj as AjaxActionResult);
            }
            else if (obj is IAjaxSecurity)
            {
                AjaxSecurity(obj as IAjaxSecurity);
            }
        }

        public static void AjaxSecurity(IList list)
        {
            foreach (Object obj in list)
            {
                if (obj is IAjaxSecurity)
                {
                    (obj as IAjaxSecurity).AjaxSecurity();
                }
            }
        }

        public static void AjaxSecurity(IAjaxSecurity ajaxEntity)
        {
            ajaxEntity.AjaxSecurity();
        }

        public static void AjaxSecurity(AjaxActionResult result)
        {
            if (result.OutObject is IAjaxSecurity)
            {
                (result.OutObject as IAjaxSecurity).AjaxSecurity();
            }
        }
    }
}
